<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "视频详情");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>
<style type="text/css">
body{
	position: relative;
}
.comment .weui-cell {
	align-items: unset;
}

.comment .weui-cell__bd {
	margin-left: 5px;
	margin-right: 5px;
}

.weui-tabbar {
	position: fixed !important;
}

.weui-search-bar__box .weui-search-bar__input {
	width: auto;
}

.playBtn{
		position:absolute;
		width:36px;
		height:36px;
		/* left:10px !important; */
		/* top: 195px !important; */
		/* bottom:10px !important; */
	}

.enlarge{
		position:absolute;
		width:36px;
		height:36px;
	/* 	right:10px !important; */
		/* top: 195px !important; */
		/* bottom:10px !important; */
}

.video .weui-cell{
	padding-bottom: 0px;
}

.video .weui-cell:before{
	border: none;
}

.weui-cells:after{
	border: none;
}

	.weui-cell:active{
		background-color: rgba(180, 180, 180, 0.2);
	}
	
	.weui-loadmore{
	margin: 5px;
	
}

</style>
<%@ include file="/WEB-INF/views/shared/master/weTitle.jsp"%>
<input type="hidden" id="articalId" value="${artical.id}" />
<input type="hidden" id="articalType" value="${artical.medioType}" />
<input type="hidden" id="customerId" value="${customer.id}" />
<input type="hidden" id="result" value="1" />
<c:if test="${custCollection == null }">
<input type="hidden" class="coll" value="1" />
</c:if>
<c:if test="${custCollection != null }">
<input type="hidden" class="coll" value="0" />
</c:if>


<div>

 <input type="hidden" class="time" value="" />

	<%-- <div class="guide weui-tabbar" style="background: rgba(0, 0, 0, 0.6);margin-bottom:45px;padding-top: 5px">
		<a class="weui-cell" style="padding: 0px 15px 5px 15px;width: 100%" href="<c:url value='/wechat/cust/invitation/posterIndex'/>">
			<div class="weui-cell__hd">
				<img style="width: 20px;height: 20px;" class="icon_img" src="<c:url value='/images/we/index/icon_horn.png' />">
			</div>
			<div class="weui-cell__bd" style="color: #ffffff;font-size: 0.6rem;letter-spacing:2px;">
				海报分享赚更多金豆啦~
			</div>
			<div class="weui-cell__ft">
				<div style="border: 1px solid #ffffff;border-radius:10px;color: #ffffff;padding: 3px 10px 0px 10px;font-size: 0.6rem">
					去分享
				</div>
			</div>
		</a>
	</div> --%>



<div>
	<video  src="${tfn:getFileUrl(artical.videoUrl)}"  id="videoShow" class="videoShow" controls="controls" style="width: 100%" preload="auto">
		your browser does not support the video tag
	</video>
</div>
<div class="coverBox">
	<img class="imgshow" src="${tfn:getFileUrl(artical.imgUrl)}" /> 		
	<img class="playBtn" src="<c:url value='/images/we/shareCode/broadcast.png'/>"  />
	<%-- <img class="enlarge" src="<c:url value='/images/we/shareCode/enlarge.png'/>"  /> --%>
</div>


<div class="weui-cells video" style="margin-top: 0px;">
		<div class="weui-cell">
			<div class="weui-cell__hd">
				<strong>${artical.title}</strong>
			</div>
	<c:choose>
	<c:when test="${custCollection == null}">		
			<div class="weui-cell__bd" style="padding-left: 5px;text-align: right;">
				<img alt="" class="collect" src="<c:url value='/images/we/shareCode/uncollect.jpg' />" style="width: 16px;height: 16px" >
		  		<span style="" class="collection">收藏</span>
			</div>
	</c:when>
	<c:when test="${custCollection != null}">		
			<div class="weui-cell__bd" style="padding-left: 5px;text-align: right;">
				<img alt="" class="collect" src="<c:url value='/images/we/shareCode/collected.jpg' />" style="width: 16px;height: 16px" >
		  		<span style="" class="collection">已收藏</span>
			</div>
	</c:when>
	</c:choose>
		</div>
		
		<div class="weui-cell">
			<div class="weui-cell__hd">
				<strong style="color:#e1361a">免费</strong>
			</div>
			
			<div class="weui-cell__bd" style="padding-left: 5px;text-align: right;">
<c:choose>
	<c:when test="${articalPraise == null}">
		<div style="padding: 10px 15px">
			<img alt="" src="<c:url value='/images/we/shareCode/browse.jpg' />" style="width: 20px; height: 10px;margin:0px 0px" >
			<span style="color:#999;margin-right: 10px">${praiseAndGlance.glanceCount}</span>
			<img alt="" id="articalThumb" src="<c:url value='/images/we/shareCode/thumb.jpg' />" style="width: 16px; height: 16px;margin:0px 0px"  > <span
				style="color: #999">${praiseAndGlance.praiseCount}</span>
		</div>
	</c:when>
	<c:when test="${articalPraise != null}">
		<div style="padding: 10px 15px">
			<img alt="" src="<c:url value='/images/we/shareCode/browse.jpg' />" style="width: 20px; height: 10px;margin:0px 0px" >
			<span style="color:#999;margin-right: 10px">${praiseAndGlance.glanceCount}</span>
			<img alt="" id="articalThumb" src="<c:url value='/images/we/shareCode/thumbed.jpg' />" style="width: 16px; height: 16px;margin:0px 0px" > <span
				style="color: #999">${praiseAndGlance.praiseCount}</span>
		</div>
	</c:when>
  </c:choose> 

	</div>
</div>
		
		
</div>


<div style="width: 100%; height: 10px; background-color: #ebebeb; margin-top: 10px;"></div>
	
<div>
	<h3 style="color: #1fa0db; margin: 4px 10px 0px 13px;">视频简介</h3>
	<div style="text-indent: 2em;padding: 0px 15px">
		${artical.introduction}
	</div>
</div>


	<div
		style="width: 100%; height: 10px; background-color: #ebebeb; margin-top: 10px;"></div>
	<div style="border: 1px solid #ebebeb; padding: 6px 4px">
		<h3 style="color: #1fa0db; margin: 4px 10px 0px 10px;">评论</h3>
	</div>
<c:if test="${empty articalComments}">
	<div class="weui-panel_body no_articalComments"
		style="text-align: center;">
		<img alt="" src="<c:url value='/images/we/personCenter/null.png' />">
		<p style="margin: 5px 20px; color: #afafaf">评论区空空如也...</p>
	</div>
</c:if>

<div class="comment weui-cells"
	style="margin-top: 0px;height: 24.5rem; overflow: scroll;">

	
		<c:forEach items="${articalComments}" var="articalComment">
		<div class="weui-cell" style="align-items: unset; border-bottom: 1px solid #e5e5e5;">
			<div class="weui-cell__hd" style="padding-right: 8px;">
				<img style="width: 40px; height: 40px; padding-top: 5px;border-radius: 50%;" src="${articalComment.customerImg}">
			</div>
			<a class="weui-cell__bd" href="<c:url value='/wechat/share/commentDetail?commentId=${articalComment.id}&type=${artical.medioType}'/>">	
				<p style="color: #E49662">
					<%-- <c:choose>
						<c:when test="${articalComment.customerName != null}">
						${articalComment.customerName}
						</c:when>
						<c:when test="${articalComment.customerName == null}"> --%>
						${articalComment.nickName}
					<%-- 	</c:when>
					</c:choose> --%>
				</p>
				<p style="color: #999; font-size: 0.6rem" class="datetime"> 
				<fmt:formatDate value="${articalComment.createTime}" type="date" dateStyle="default" pattern="yyyy-MM-dd HH:mm:ss"  />
				</p>
				<p class="showTwo" style="color: #333;">
				<c:choose>
					<c:when test="${articalComment.replyedId != null}">
						回复<%-- <c:choose>
								<c:when test="${articalComment.replyedName != null}">
								<span style="color: #808BC1">@${articalComment.replyedName}:</span>
								</c:when>
								<c:when test="${articalComment.replyedName == null}"> --%>
								<span style="color: #808BC1">@${articalComment.replyedNickName}:</span>
						<%-- 		</c:when>
							</c:choose> --%>
						</c:when>
				</c:choose>
				${articalComment.comment}
				</p>
			</a>
			<div class="weui-cell__ft">	
					<p>
					<input type="hidden" class="commentId" value="${articalComment.id}">
					<c:choose>
						<c:when test="${articalComment.praiseCustomerId == null}">
								<img alt="" src="<c:url value='/images/we/shareCode/thumb.jpg' />" style="width: 16px; height: 16px; margin: 0px 0px"class="commentThumb"> 
			 					<span style="color: #999">${articalComment.praiseCount}</span>
						</c:when>
						<c:when test="${articalComment.praiseCustomerId != null}">
								<img alt="" src="<c:url value='/images/we/shareCode/thumbed.jpg' />" style="width: 16px; height: 16px; margin: 0px 0px"class="commentThumb"> 
			 					<span style="color: #999">${articalComment.praiseCount}</span>
						</c:when>
					</c:choose>
					</p>
					<p style="margin-top: 2.2rem">
							<input type="hidden" class="customerId" value="${articalComment.customerId}">
							<img alt="" src="<c:url value='/images/we/shareCode/pen.jpg' />" style="width: 16px; height: 16px; margin: 0px 0px"> 
							<span style="color: #999;" class="reply">回复</span>
					</p>
				</div>
			</div>
	</c:forEach>

</div>

<div class="weui-loadmore bottomLoadding" hidden style="background-color: white; width: 85%;z-index:1999;">
    <i class="weui-loading"></i> <span class="weui-loadmore__tips">正在加载</span>
</div>
<div class="weui-loadmore weui-loadmore_line bottomNomore" hidden style="background-color: white; width: 85%;">
	<span class="weui-loadmore__tips">没有更多了..</span>
</div>

<div style="height: 2rem">
</div>




<div class="weui-search-bar weui-tabbar" id="searchBar">
	<form class="weui-search-bar__form">
		<div class="weui-search-bar__box">
			<img alt="" src="<c:url value='/images/we/shareCode/bluePen.jpg' />"
				style="width: 16px; height: 16px;"> <input type="search"
				class="weui-search-bar__input" id="searchInput" placeholder="我来说两句"
				required=""> <a href="javascript:" class="weui-icon-clear"
				id="searchClear"></a>
		</div>
		<label class="weui-search-bar__label" id="searchText"> <img
			alt="" src="<c:url value='/images/we/shareCode/bluePen.jpg' />"
			style="width: 16px; height: 16px; margin: 0px 0px"> <span>我来说两句</span>
		</label>
	</form>
	<a href="javascript:void(0);" class="weui-search-bar__cancel-btn"
		id="sendMessage">发送</a>
</div>
	
	<%-- <div class="guideToShare" style="background: rgba(0, 0, 0, 0.6); position: absolute; top: 0px; left: 0px; text-align: center; z-index: 501;" hidden>
		<div class="guide1" style="text-align: right;padding-right: 1.2rem">
		<img style="width: 260px;" src="<c:url value='/images/we/invitationIndex/guide1.png'/>">
		</div>	
		<img class="guide1"  onclick="closeGuide1()" style="width: 100px;padding-top: 30px;padding-left: 1rem;" src="<c:url value='/images/we/invitationIndex/guide2.png'/>">
		
		<div class="guide2" style="text-align: center;margin-top: 16rem" hidden>		
		<img  onclick="closeGuide()" style="width: 100px;padding-top: 30px;padding-left: 30px;" src="<c:url value='/images/we/invitationIndex/guide2.png'/>">
		</div>	
		
		<div class="guide2" style="text-align: center;margin-top: 1rem" hidden>
		<img style="width: 260px;" src="<c:url value='/images/we/invitationIndex/guide3.png'/>">
		</div>	
	</div> --%>

	<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
	<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>
	<%@ include file="/WEB-INF/views/shared/scripts/tabmob.jsp"%>
	<script type="text/javascript"
		src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>

<script type="text/javascript">

	var replyedId;
	
	function goback() {
		window.history.back(-1);
	}


	
		

	$(function() {		
		/* $(".guideToShare").width(window.screen.availWidth);
		$(".guideToShare").height(window.screen.availHeight);
		showGuide(); */
		

		toThumbArtical();
		refreshEventBinding();
		sendMessage();
		adjustPicture();
		
		scrollUpload();
		
		/* var result = $("#result").val();
		if(result == 1){
		 	setTimeout(toStudy,90000);
		} */
		
	})
	//调整图片大小
	function adjustPicture(){
		
		$("#content img").css({width:"100%"});
		
	}
	
	function refreshEventBinding() {
		toThumbComment();
		$(".reply").on('click', function() {
			var $reply = $(this);
			replyedId = $reply.parent().find(".customerId").val();
			$("#searchInput").focus();
			$(".weui-search-bar").addClass("weui-search-bar_focusing");
		})
	}

	//文章去点赞
	function toThumbArtical() {
		$("#articalThumb").click(function() {
			var articalId = $("#articalId").val();
			var url = $.getVirtualPath() + "/wechat/share/articalThumb";
			$.post(url, {
				articalId : articalId
			}, function(res) {

				if (res === false) {
					articalThumb();
				} else if (res === true) {
					$.toast("你已赞过了哟！", "text");
				}
			}, 'json')
		})
	}

	function sendMessage() {
		$("#sendMessage").click(function() {

			var customerId = $("#customerId").val();
			var content = $("#searchInput").val();

			if ($.isNull(content)) {
				$.toast("还没留下点什么哟~", "text");
				return;
			}
			var articalId = $("#articalId").val();

			if ($.isNull(replyedId)) {
				postArticalMessage(content, articalId);
				return;
			}
			postCommentMessage(content, articalId, replyedId);
			replyedId = null;
		})
	}

	//文章点赞成功切换点赞图片
	function articalThumb() {
		$("#articalThumb").attr("src",
				"<c:url value='/images/we/shareCode/thumbed.jpg' />");
		var count = $("#articalThumb").next().text();
		count = Number(count) + 1;
		$("#articalThumb").next().text(count);
	}


	
	function  postArticalMessage(content,articalId){
	    var url=$.getVirtualPath()+"/wechat/share/postMessage";
	   /*  content = utf16toEntities(content); */
	    $.post(url,{content:content,articalId:articalId},function(res){
	    	 addCommentForArtical(res);
        	$(".no_articalComments").hide();
        },'json')
	}
		

	//评论去点赞
	function toThumbComment() {
		$(".commentThumb").on('click',function() {
				var $comment = $(this);
				var commentId = $comment.parent().find(".commentId").val();
				var url = $.getVirtualPath()+ "/wechat/share/commentThumb";
				$.post(url,{commentId : commentId},function(res) {
						if (res === false) {
							$comment.attr("src","<c:url value='/images/we/shareCode/thumbed.jpg' />");
							var $praiseCount = $comment.parent().find("span");
							var count = $praiseCount.text();
							count = Number(count) + 1;
							$praiseCount.text(count);
							} else if (res === true) {
								$.toast("你已赞过了哟！", "text");
							}
				}, 'json')
		})

	};

	function postCommentMessage(content,articalId,replyedId){
		/* content = utf16toEntities(content); */
		 var url=$.getVirtualPath()+"/wechat/share/postMessage";
	        $.post(url,{content:content,articalId:articalId,replyedId:replyedId},function(res){
	        	addCommentForReply(res);
	        },'json');
	}


	//解除绑定click事件
	function unbindClick() {
		$(".reply").unbind('click');
		$(".commentThumb").unbind('click');
	} 

	//十六位转八位,利于存储表情
/* 	function utf16toEntities(str) {
            var patt=/[\ud800-\udbff][\udc00-\udfff]/g;
            // 检测utf16字符正则
            str = str.replace(patt, function(char){
                var H, L, code;
                if (char.length===2) {
                    H = char.charCodeAt(0);
                    // 取出高位
                    L = char.charCodeAt(1);
                    // 取出低位
                    code = (H - 0xD800) * 0x400 + 0x10000 + L - 0xDC00;
                    // 转换算法
                    return "&#" + code + ";";
                } else {
                    return char;
                }
            });
            return str;
        }
	 */
	
	//八位转十六位，利于展示表情
/* 	 function entitiestoUtf16(str){
            // 检测出形如&#12345;形式的字符串
            var strObj=utf16toEntities(str);
            var patt = /&#\d+;/g;
            var H,L,code;
            var arr = strObj.match(patt)||[];
            for (var i=0;i<arr.length;i++){
                code = arr[i];
                code=code.replace('&#','').replace(';','');
                // 高位
                H = Math.floor((code-0x10000) / 0x400)+0xD800;
                // 低位
                L = (code - 0x10000) % 0x400 + 0xDC00;
                code = "&#"+code+";";
                var s = String.fromCharCode(H,L);
                strObj.replace(code,s);
            }
            return strObj;
        } */ 


		$(function () {
			$(".videoShow").hide();
			$(".imgshow").show();
			$width = $(".videoShow").width();
			$height = $(".videoShow").height();
			$(".coverBox").width($width);
			$(".coverBox").height($height);
			
			$playWidth = $(".coverBox").width();
			$playHeight =$(".coverBox").height();
			
	/* 		var playLeft = $width/2 - $playWidth/2;
			var platTop = $height/2 - $playHeight/2; */
			
			$(".playBtn").css("left",10);
			$(".playBtn").css("top",$playHeight - 3);
			
			$(".enlarge").css("right",10);
			$(".enlarge").css("top",$playHeight - 3);
			
			$(".imgshow").width($width);
			$(".imgshow").height($height);
			
			$(".imgshow").click(function () {
				imgClick();
			});
			
			$(".playBtn").click(function(){
				imgClick();
			});
			
		});
		

		function imgClick(){
			$(".imgshow").hide();
			$(".playBtn").hide();
			$(".videoShow").show();
		/* 	myFunction(); */
			$(".videoShow").get(0).play();
			$(".coverBox").hide();
		}
		
		var time = $(".coll").val();
		$(".collect").on("click",function(){
			if(time == 1){
				var articalId = $("#articalId").val();
				var articalType=$("#articalType").val();
				var url=$.getVirtualPath()+"/wechat/cust/colAndFoot/addCollect?thingId="+articalId+"&type="+articalType;
				var result=$.getJsonPost(url);
				if(result === true){
					$.toast("加入收藏成功","text");
					$(".collect").attr("src","<c:url value='/images/we/shareCode/collected.jpg' />");
					$(".collection").html("已收藏");
					time = 0;
				}else{
					$.toast("收藏失败","text");
				} 
				
			}else if(time == 0){
				var articalId = $("#articalId").val();
				var articalType=$("#articalType").val();
				var url=$.getVirtualPath()+"/wechat/cust/colAndFoot/delete?thingId="+articalId+"&type="+articalType;
				var result=$.getJsonPost(url);
				if(result === true){
					$.toast("取消收藏成功","text");
					$(".collect").attr("src","<c:url value='/images/we/shareCode/uncollect.jpg' />");
					$(".collection").html("收藏");
					time = 1;
				}else{
					$.toast("取消收藏失败","text");
				}
			}	
		})


	//上拉加载
	function scrollUpload(){
		$(".comment").scroll(
				function() {
					var $this = $(this);
					viewH = $(this).height();//可见高度 
					contentH = $(this).get(0).scrollHeight;//内容高度
					scrollTop = $(this).scrollTop();//滚动高度
					if (contentH - viewH - scrollTop == 0) {
						$(".bottomLoadding").show();
						$("#searchBar").hide();
						if(pullUpLoading() === true){
							setTimeout(function() {
								$(".bottomLoadding").hide();
								$("#searchBar").show();
							}, 10);
						}else{
							
							$(".bottomNomore").show();
							$(".bottomLoadding").hide();

							setTimeout(function() {
								$(".bottomNomore").hide();
								$("#searchBar").show();
							}, 2000); 
							
						}
						
					}
				})
	}
	


	function pullUpLoading(){
		 var url=$.getVirtualPath()+"/wechat/share/pullUpLoading";
		 var beforeTime = $.trim($("p.datetime").last().html());
		 var articalId = $("#articalId").val();
		 $.post(url,{beforeTime:beforeTime,articalId:articalId},function(rm){
			 if(rm == null){return false;}
			 $.each(rm,function(index,item){
				if(item.replyedId ==  null){
					addCommentForArtical(item,"end");
				}else{
					addCommentForReply(item,"end");
				} 
			 });	 
		 },'json') 
		return true;
	}
		

	
	
	//提取ajax用来加载评论文章
	function  addCommentForArtical(res,location){
		unbindClick();
    	var href = $.getVirtualPath() + "/wechat/share/commentDetail?commentId=" + res.id+"&type=" +$("#articalType").val();
    	/* res.comment = entitiestoUtf16(res.comment); */
    	/* var userName = $.isNull(res.customerName)?res.nickName : res.customerName;  */
    	var imgStr = res.praiseCustomerId == null? "\t\t\t <img alt=\"\" src=\"<c:url value='/images/we/shareCode/thumb.jpg' />\" style=\"width: 16px; height: 16px; margin: 0px 0px\"class=\"commentThumb\"> \n":
    		"\t\t\t <img alt=\"\" src=\"<c:url value='/images/we/shareCode/thumbed.jpg' />\" style=\"width: 16px; height: 16px; margin: 0px 0px\"class=\"commentThumb\"> \n";
    	
    	
    	var comment =$("<div class=\"weui-cell\" style=\"align-items: unset; border-bottom: 1px solid #e5e5e5;\"> \n" +
    			"\t <div class=\"weui-cell__hd\" style=\"padding-right: 8px;\"> \n" +
    			"\t\t <img style=\"width: 40px; height: 40px; padding-top: 5px;border-radius: 50%\" \n" +
    			"\t\t\t src=\"" +res.customerImg+"\"> \n" +
    			"\t </div> \n" +
    			"\t <a class=\"weui-cell__bd\" href=\""+href + "\" > \n" +
    			"\t\t <p style=\"color: #E49662\">" + res.nickName + "</p> \n" +
    			"\t\t <p style=\"color: #999; font-size: 0.6rem\" class=\"datetime\" >" + res.createTime + "</p> \n" +
    			"\t\t <P class=\"showTwo\" style=\"color: #333;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;overflow: hidden;\">\n" +
    			"\t\t\t "+res.comment +"\n" +
    			"\t\t </P> \n" +
    			"\t </a> \t \n" +
    			"\t <div class=\"weui-cell__ft\"> \n" +
    			"\t\t <p> \n" +
    			"\t\t\t <input type=\"hidden\" class=\"commentId\" value=\" " + res.id + " \">" +
    			imgStr    +			
    			"\t\t\t <span style=\"color: #999\">"+res.praiseCount +"</span> \n" +
    			"\t\t </p> \n" +
    			"\t\t <p style=\"margin-top: 2.2rem\">\n" +
    			"\t\t\t <input type=\"hidden\" class=\"customerId\" value=\""+res.customerId +"\">" +
    			"\t\t\t <img alt=\"\" src=\"<c:url value='/images/we/shareCode/pen.jpg' />\" style=\"width: 16px; height: 16px; margin: 0px 0px\"> \n" +
    			"\t\t\t <span style=\"color: #999;\" class=\"reply\">回复</span>\n" +
    			"\t\t </p>\n" +
    			"\t </div>\n" +
    			" </div>");
    	if('end' === location){
    		
    		$(".comment").append(comment);
    	}else{
    		$(".comment").prepend(comment);
    	}
    	
    	refreshEventBinding(); 	
	}
	
	
	//提取ajax用来加载回复评论
	function addCommentForReply(res,location){
		unbindClick();
    	/* res.comment = entitiestoUtf16(res.comment); */
    	/* var userName = $.isNull(res.customerName)?res.nickName : res.customerName;
    	var replyedName = $.isNull(res.replyedName)?res.replyedNickName:res.replyedName; */
    	var imgStr = res.praiseCustomerId == null? "\t\t\t <img alt=\"\" src=\"<c:url value='/images/we/shareCode/thumb.jpg' />\" style=\"width: 16px; height: 16px; margin: 0px 0px\"class=\"commentThumb\"> \n":
    		"\t\t\t <img alt=\"\" src=\"<c:url value='/images/we/shareCode/thumbed.jpg' />\" style=\"width: 16px; height: 16px; margin: 0px 0px\"class=\"commentThumb\"> \n";
    	
    	
    	
    	var href = $.getVirtualPath() + "/wechat/share/commentDetail?commentId=" + res.id+"&type=" +$("#articalType").val();
    	var comment =$("<div class=\"weui-cell\" style=\"align-items: unset; border-bottom: 1px solid #e5e5e5;\"> \n" +
    			"\t <div class=\"weui-cell__hd\" style=\"padding-right: 8px;\"> \n" +
    			"\t\t <img style=\"width: 40px; height: 40px; padding-top: 5px;border-radius: 50%\" \n" +
    			"\t\t\t src=\"" +res.customerImg+"\"> \n" +
    			"\t </div> \n" +
    			"\t <a class=\"weui-cell__bd\" href=\""+href + "\" > \n" +
    			"\t\t <p style=\"color: #E49662\"  >" + res.nickName + "</p> \n" +
    			"\t\t <p style=\"color: #999; font-size: 0.6rem\"  class=\"datetime\" >" + res.createTime + "</p> \n" +
    			"\t\t <P class=\"showTwo\" style=\"color: #333;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;overflow: hidden;\">\n" +
    			"\t\t\t 回复 <span style=\"color: #808BC1\" class=\"reply\">"+"@" + res.replyedNickName + "</span>："+res.comment +"\n" +
    			"\t\t </P> \n" +
    			"\t </a> \t \n" +
    			"\t <div class=\"weui-cell__ft\"> \n" +
    			"\t\t <p> \n" +
    			"\t\t\t <input type=\"hidden\" class=\"commentId\" value=\" " + res.id + " \">" +
    			imgStr    	 +
    			"\t\t\t <span style=\"color: #999\">"+res.praiseCount +"</span> \n" +
    			"\t\t </p> \n" +
    			"\t\t <p style=\"margin-top: 2.2rem\">\n" +
    			"\t\t\t <input type=\"hidden\" class=\"customerId\" value=\""+res.customerId +"\">" +
    			"\t\t\t <img alt=\"\" src=\"<c:url value='/images/we/shareCode/pen.jpg' />\" style=\"width: 16px; height: 16px; margin: 0px 0px\"> \n" +
    			"\t\t\t <span style=\"color: #999;\" class=\"reply\">回复</span>\n" +
    			"\t\t </p>\n" +
    			"\t </div>\n" +
    			" </div>");

    	if('end' === location){
    		$(".comment").append(comment);
    	}else{
    		$(".comment").prepend(comment);
    	}	
    	refreshEventBinding();	
	}
		
	/* ------------------------------微信分享-------------------------- */	
	var titleName =$("#title").val();
	var key = $("#articalId").val();
	var medioType = $("#articalType").val();


	/* if($.isNull($("#infoThumbnailId").val())){
		$imgUrl = "http://www.putiyoli.net/ares/images/logo.png";
	}else{
		$imgUrl = "${tfn:getFileUrl(info.infoThumbnailId)}";
		console.log($imgUrl);
	} */
	
	var url=$.getVirtualPath()+"/wechat/cust/personCenter/shareSignature";
	var linkHref=location.href.split('#')[0];
	var href=encodeURIComponent(linkHref);
	
	console.log(href);
	var resultJson=$.getJsonPost(url,"href="+href);
	console.log(resultJson);

	var config={
			debug: false,
		  	appId: resultJson.jsapiSignature.appId,// 公众号的唯一标识
		  	timestamp: resultJson.jsapiSignature.timestamp,// 生成签名的时间戳
		  	nonceStr: resultJson.jsapiSignature.nonceStr,// 生成签名的随机串
		  	signature: resultJson.jsapiSignature.signature,// 签名
		  	jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline']
		}
	wx.config(config);
	// 微信事件
	wx.ready(function () {
		// 分享朋友
		wx.onMenuShareAppMessage({
		    title: "普天永利-资讯",//resultJson.linkName+'的邀请码',
		    desc:  titleName,
		    link:  linkHref,
		    imgUrl: "http://www.hdoit.com/ares/images/logo.png",
		    success: function () {
				console.log(arguments);
				var url = $.getVirtualPath()+"/wechat/share/consult?shareId="+key+"&shareType="+medioType;
				$.getTextPost(url);
		    },error:function(){
		    }
		});
		console.log(config);
		//分享到朋友圈
		wx.onMenuShareTimeline({
			title: "普天永利-资讯",
		    link:  linkHref,
		    imgUrl: "http://www.hdoit.com/ares/images/logo.png",
			success: function () {
				/* var url = $.getVirtualPath()+"/wechat/share/consult?shareId="+key+"&shareType="+medioType;
				$.getTextPost(url); */
			}
		});
		// 微信错误处理机制
		wx.error(function (res) {
			console.log(res.errMsg);
		});
	});	
	
	
	function toStudy(){
		if(medioType == "video"){	
			var url = $.getVirtualPath()+"/wechat/share/toStudy?shareId="+key+"&shareType="+medioType;
			var temp = $("#result").val($.getJsonPost(url));
		}
	}
	

	/* //显示 引导 遮罩层
	function showGuide() {
		var id = $("#customerId").val();		
		//openDatabase方法打开已经存在的数据库，如果不存在将会创建一个数据库
        var db = window.openDatabase("mydatabase", "1.0", "我的数据库", 20000);       
                    
        //创建数据表
        var sql = "CREATE TABLE  if not exists videoTable (id REAL UNIQUE)";
        db.transaction(function (tx) {
            tx.executeSql(sql,
            []);
        });
        //查数据
       db.transaction(function (tx) {
           tx.executeSql("select * from videoTable where id= ?", 
           [id],
           function(tx,result){ 
        	   if(result.rows.length==1){
        		   $(".guideToShare").hide();
        	   }
			   if(result.rows.length==0){
				   $(".guideToShare").show();
				   db.transaction(function (tx) {
			            tx.executeSql("INSERT INTO videoTable (id) values(?)", 
			            [id],
			            function(tx,result){ }, 
			        	function(tx, error){ });
			        }); 
        	   }
           }, 
       	   function(tx, error){});
       });
	}
//隐藏引导遮罩层
	function closeGuide() {
		$(".guideToShare").hide();
	}
	//隐藏引导遮罩层
	function closeGuide1() {
		$(".guide1").hide();
		$(".guide2").show();
	}	 */

	</script>


	<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
